package com.jing21.learn;

import com.jing21.learn.common.learn.CorsResourceServerConfigurerAdapter;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.security.oauth2.resource.UserInfoRestTemplateFactory;
import org.springframework.cloud.client.SpringCloudApplication;
import org.springframework.cloud.client.loadbalancer.LoadBalanced;
import org.springframework.cloud.netflix.feign.EnableFeignClients;
import org.springframework.context.annotation.Bean;
import org.springframework.security.oauth2.config.annotation.web.configuration.EnableResourceServer;
import org.springframework.validation.beanvalidation.MethodValidationPostProcessor;

/**
 * Created by 郑靖 on 2017/9/27.
 */
@SpringCloudApplication
@EnableResourceServer
@EnableFeignClients
public class BasicApiApplication extends CorsResourceServerConfigurerAdapter {

    public static void main(String[] args) {

        SpringApplication.run(BasicApiApplication.class, args);
    }

    @Bean
    public MethodValidationPostProcessor validationPostProcessor() {
        return new MethodValidationPostProcessor();
    }

    @Bean
    @LoadBalanced
    public org.springframework.security.oauth2.client.OAuth2RestTemplate restTemplate(UserInfoRestTemplateFactory
                                                                                              factory) {

        return factory.getUserInfoRestTemplate();
    }

}

